#ifndef TEST_H
#define TEST_H

#include <QWidget>

namespace Ui {
class Test;
}

class Test : public QWidget
{
    Q_OBJECT

public:
    explicit Test(QWidget *parent = 0);
    ~Test();

public:
    enum ButtonStyle{
        ButtonStyle_Rect=0,
        ButtonStyle_CircleIn=1,
        ButtonStyle_CircleOut=2,
        ButtonStyle_Image=3
    };
protected:
    void mousePressEvent(QMouseEvent *);
    void resizeEvent(QResizeEvent *);
    void paintEvent(QPaintEvent *);
    void drawBg(QPainter *painter);
    void drawSlider(QPainter *painter);
    void drawText(QPainter *painter);
    void drawImage(QPainter *painter);

private:
    bool checked;
    ButtonStyle buttonStyle;
    QColor bgColorOff;
    QColor bgColorOn;
    QColor sliderColorOff;
    QColor sliderColorOn;
    QColor textColorOff;
    QColor textColorOn;
    QString textOff;
    QString textOn;
    QString imageOff;
    QString imageOn;

    int space;
    int rectRadius;

    int step;
    int startX;
    int endX;
    QTimer* timer;

private slots:
    void updateValue();

public:
    bool getChecked() const{
        return checked;
    }

    ButtonStyle getButtonStyle() const{
        return buttonStyle;
    }

    QColor getBgColorOff() const{
        return bgColorOff;
    }

    QColor getBgColorOn() const{
        return bgColorOn;
    }

    QColor getSliderColorOff() const{
        return sliderColorOff;
    }

    QColor getSliderColorOn() const{
        return sliderColorOn;
    }

    QColor getTextColorOff() const{
        return textColorOff;
    }

    QColor getTextColorOn() const{
        return textColorOn;
    }

    QString getTextOff() const{
        return textOff;
    }

    QString getTextOn() const{
        return textOn;
    }

    QString getImageOff() const{
        return imageOff;
    }

    QString getImageOn() const{
        return imageOn;

    }

    int getSpace() const{
        return space;
    }

    int getRectRadius() const{
        return rectRadius;
    }

public slots:
    void setChecked(bool checked);
    //设置风格样式
    void setButtonStyle(ButtonStyle buttonStyle);

    //设置背景颜色
    void setBgColor(QColor bgColorOff, QColor bgColorOn);
    //设置滑块颜色
    void setSliderColor(QColor sliderColorOff, QColor sliderColorOn);
    //设置文本颜色
    void setTextColor(QColor textColorOff, QColor textColorOn);

    //设置文本
    void setText(QString textOff, QString textOn);

    //设置背景图片
    void setImage(QString imageOff, QString imageOn);

    //设置间隔
    void setSpace(int space);
    //设置圆角角度
    void setRectRadius(int rectRadius);

signals:
    void checkedChanged(bool checked);

private:
    Ui::Test *ui;
};

#endif // TEST_H
